// Copyright 2022 a.o.smith ALL Rights Reserved
package com.liuxinlong.modules.assets.controller;

import com.liuxinlong.annotation.LogAnnotation;
import com.liuxinlong.constant.LogBusinessConstants;
import com.liuxinlong.constant.LogOperateConstants;
import com.liuxinlong.modules.assets.controller.request.QueryInvestmentConfigReq;
import com.liuxinlong.modules.assets.controller.request.UpdateInvestmentConfigReq;
import com.liuxinlong.modules.assets.service.InvestmentConfigService;
import com.liuxinlong.modules.common.controller.request.BaseDeleteReq;
import com.liuxinlong.modules.common.controller.response.BaseResp;
import com.liuxinlong.modules.entity.AssetsInvestmentCommonConfig;
import com.liuxinlong.modules.entity.AssetsInvestmentConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 固资在线测算配置控制层
 *
 * @author liuxinlong@hotwater.com.cn
 * @version 1.0.0
 * @since 2024-09-06
 */
@RestController
@RequestMapping("/assets/investment-config")
public class InvestmentConfigController {

    @Autowired
    private InvestmentConfigService investmentConfigService;

    /**
     * 分页查询固资在线测算配置信息列表
     *
     * @param req 请求信息
     * @return 固资在线测算配置信息列表
     */
    @PostMapping("page")
    public BaseResp pageInvestmentConfigList(@RequestBody QueryInvestmentConfigReq req) {
        Map<String, Object> queryMap = new HashMap<>();
        queryMap.put("startNum", req.getStartNum());
        queryMap.put("pageSize", req.getPageSize());
        queryMap.put("configName", req.getConfigName());
        queryMap.put("configType", req.getConfigType());
        queryMap.put("status", req.getStatus());
        List<Map<String, Object>> dataList = investmentConfigService.pageInvestmentConfigInfo(queryMap);
        int totalNum = investmentConfigService.getInvestmentConfigInfoCount(queryMap);
        BaseResp resp = new BaseResp();
        resp.setRetMessage("分页查询固资在线测算信息成功");
        resp.setDataList(dataList);
        resp.setTotalNum(totalNum);
        return resp;
    }

    /**
     * 新增固资在线测算配置信息
     *
     * @param req 请求信息
     * @return 成功标识
     */
    @PostMapping("add")
    @LogAnnotation(value = "新增固资在线测算配置信息", business = LogBusinessConstants.INVESTMENT_CONFIG, operateType = LogOperateConstants.OPERATE_ADD)
    public BaseResp addInvestmentConfigInfo(@RequestBody UpdateInvestmentConfigReq req) {
        AssetsInvestmentConfig configInfo = new AssetsInvestmentConfig();
        configInfo.setConfigName(req.getConfigName());
        configInfo.setConfigType(req.getConfigType());
        configInfo.setConfigBrand(req.getConfigBrand());
        configInfo.setConfigClass(req.getConfigClass());
        configInfo.setConfigChannel(req.getConfigChannel());
        configInfo.setConfigYear(req.getConfigYear());
        configInfo.setConfigAssetsType(req.getConfigAssetsType());
        configInfo.setParamOne(req.getParamOne());
        configInfo.setParamTwo(req.getParamTwo());
        configInfo.setParamThree(req.getParamThree());
        configInfo.setParamFour(req.getParamFour());
        configInfo.setParamFive(req.getParamFive());
        configInfo.setParamSix(req.getParamSix());
        configInfo.setParamSeven(req.getParamSeven());
        configInfo.setParamEight(req.getParamEight());
        configInfo.setParamNine(req.getParamNine());
        configInfo.setParamTen(req.getParamTen());
        configInfo.setRemark(req.getRemark());
        investmentConfigService.addInvestmentConfigInfo(configInfo);
        BaseResp resp = new BaseResp();
        resp.setRetMessage("新增固资在线测算配置信息成功");
        return resp;
    }

    /**
     * 修改固资在线测算信息
     *
     * @param req 请求信息
     * @return 成功标识
     */
    @PostMapping("update")
    @LogAnnotation(value = "修改固资在线测算配置信息", business = LogBusinessConstants.INVESTMENT_CONFIG, operateType = LogOperateConstants.OPERATE_MODIFY)
    public BaseResp updateInvestmentConfigInfo(@RequestBody UpdateInvestmentConfigReq req) {
        AssetsInvestmentConfig configInfo = new AssetsInvestmentConfig();
        configInfo.setId(req.getId());
        configInfo.setConfigName(req.getConfigName());
        configInfo.setConfigType(req.getConfigType());
        configInfo.setConfigBrand(req.getConfigBrand());
        configInfo.setConfigClass(req.getConfigClass());
        configInfo.setConfigChannel(req.getConfigChannel());
        configInfo.setConfigYear(req.getConfigYear());
        configInfo.setConfigAssetsType(req.getConfigAssetsType());
        configInfo.setParamOne(req.getParamOne());
        configInfo.setParamTwo(req.getParamTwo());
        configInfo.setParamThree(req.getParamThree());
        configInfo.setParamFour(req.getParamFour());
        configInfo.setParamFive(req.getParamFive());
        configInfo.setParamSix(req.getParamSix());
        configInfo.setParamSeven(req.getParamSeven());
        configInfo.setParamEight(req.getParamEight());
        configInfo.setParamNine(req.getParamNine());
        configInfo.setParamTen(req.getParamTen());
        configInfo.setRemark(req.getRemark());
        investmentConfigService.updateInvestmentConfigInfo(configInfo);
        BaseResp resp = new BaseResp();
        resp.setRetMessage("修改固资项目信息成功");
        return resp;
    }

    /**
     * 删除固资在线测算信息
     *
     * @param req 请求信息
     * @return 成功标识
     */
    @PostMapping("delete")
    @LogAnnotation(value = "删除固资在线测算配置信息", business = LogBusinessConstants.INVESTMENT_CONFIG, operateType = LogOperateConstants.OPERATE_DELETE)
    public BaseResp deleteInvestmentConfigInfo(@RequestBody BaseDeleteReq req) {
        investmentConfigService.deleteInvestmentConfigInfo(req.getId());
        BaseResp resp = new BaseResp();
        resp.setRetMessage("删除固资在线测算信息成功");
        return resp;
    }

    /**
     * 修改固资在线测算配置状态信息
     *
     * @param req 请求信息
     * @return 成功标识
     */
    @PostMapping("status")
    @LogAnnotation(value = "修改固资在线测算配置状态信息", business = LogBusinessConstants.INVESTMENT_CONFIG, operateType = LogOperateConstants.OPERATE_DELETE)
    public BaseResp updateInvestmentConfigStatus(@RequestBody UpdateInvestmentConfigReq req) {
        investmentConfigService.updateInvestmentConfigStatus(req.getId(),req.getStatus());
        BaseResp resp = new BaseResp();
        resp.setRetMessage("固资在线测算配置状态信息修改成功");
        return resp;
    }


    /**
     * 分页查询固资在线测算配置信息列表
     *
     * @param req 请求信息
     * @return 固资在线测算配置信息列表
     */
    @PostMapping("common-page")
    public BaseResp pageInvestmentCommonConfigList(@RequestBody QueryInvestmentConfigReq req) {
        Map<String, Object> queryMap = new HashMap<>();
        queryMap.put("startNum", req.getStartNum());
        queryMap.put("pageSize", req.getPageSize());
        queryMap.put("configName", req.getConfigName());
        queryMap.put("configType", req.getConfigType());
        queryMap.put("status", req.getStatus());
        List<Map<String, Object>> dataList = investmentConfigService.pageInvestmentCommonConfigInfo(queryMap);
        int totalNum = investmentConfigService.getInvestmentCommonConfigInfoCount(queryMap);
        BaseResp resp = new BaseResp();
        resp.setRetMessage("分页查询固资在线测算信息成功");
        resp.setDataList(dataList);
        resp.setTotalNum(totalNum);
        return resp;
    }

    /**
     * 新增固资在线测算配置信息
     *
     * @param req 请求信息
     * @return 成功标识
     */
    @PostMapping("common-add")
    @LogAnnotation(value = "新增固资在线测算配置信息", business = LogBusinessConstants.INVESTMENT_CONFIG, operateType = LogOperateConstants.OPERATE_ADD)
    public BaseResp addInvestmentCommonConfigInfo(@RequestBody UpdateInvestmentConfigReq req) {
        AssetsInvestmentCommonConfig configInfo = new AssetsInvestmentCommonConfig();
        configInfo.setConfigName(req.getConfigName());
        configInfo.setConfigType(req.getConfigType());
        configInfo.setStatus(req.getStatus());
        configInfo.setModifiable(req.getModifiable());
        investmentConfigService.addInvestmentCommonConfigInfo(configInfo);
        BaseResp resp = new BaseResp();
        resp.setRetMessage("新增固资在线测算配置信息成功");
        return resp;
    }

    /**
     * 修改固资在线测算信息
     *
     * @param req 请求信息
     * @return 成功标识
     */
    @PostMapping("common-update")
    @LogAnnotation(value = "修改固资在线测算配置信息", business = LogBusinessConstants.INVESTMENT_CONFIG, operateType = LogOperateConstants.OPERATE_MODIFY)
    public BaseResp updateInvestmentCommonConfigInfo(@RequestBody UpdateInvestmentConfigReq req) {
        AssetsInvestmentCommonConfig configInfo = new AssetsInvestmentCommonConfig();
        configInfo.setId(req.getId());
        configInfo.setConfigName(req.getConfigName());
        configInfo.setConfigType(req.getConfigType());
        configInfo.setStatus(req.getStatus());
        configInfo.setRemark(req.getRemark());
        investmentConfigService.updateInvestmentCommonConfigInfo(configInfo);
        BaseResp resp = new BaseResp();
        resp.setRetMessage("修改固资项目信息成功");
        return resp;
    }

    /**
     * 删除固资在线测算信息
     *
     * @param req 请求信息
     * @return 成功标识
     */
    @PostMapping("common-delete")
    @LogAnnotation(value = "删除固资在线测算配置信息", business = LogBusinessConstants.INVESTMENT_CONFIG, operateType = LogOperateConstants.OPERATE_DELETE)
    public BaseResp deleteInvestmentCommonConfigInfo(@RequestBody BaseDeleteReq req) {
        investmentConfigService.deleteInvestmentCommonConfigInfo(req.getId());
        BaseResp resp = new BaseResp();
        resp.setRetMessage("删除固资在线测算信息成功");
        return resp;
    }

    /**
     * 修改固资在线测算通用配置状态信息
     *
     * @param req 请求信息
     * @return 成功标识
     */
    @PostMapping("common-status")
    @LogAnnotation(value = "修改固资在线测算通用配置状态信息", business = LogBusinessConstants.INVESTMENT_CONFIG, operateType = LogOperateConstants.OPERATE_DELETE)
    public BaseResp updateInvestmentCommonConfigStatus(@RequestBody UpdateInvestmentConfigReq req) {
        investmentConfigService.updateInvestmentCommonConfigStatus(req.getId(),req.getStatus());
        BaseResp resp = new BaseResp();
        resp.setRetMessage("固资在线测算通用配置状态信息修改成功");
        return resp;
    }

}
